package com.dengyuanke.upms.logic.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dengyuanke.upms.domain.entity.Dict;
import com.dengyuanke.upms.domain.entity.DictItem;
import com.dengyuanke.upms.logic.mapper.DictMapper;
import com.dengyuanke.upms.logic.service.IDictItemService;
import com.dengyuanke.upms.logic.service.IDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 字典表 服务实现类
 * </p>
 *
 * @author dengyuanke
 * @since 2019-06-29
 */
@Service
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements IDictService {

    @Autowired
    private IDictItemService dictItemService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean removeDict(Long id) {
        dictItemService.remove(Wrappers.<DictItem>lambdaQuery().eq(DictItem::getDictId, id));
        return this.removeById(id);
    }
}
